set -e
#准备
tagname=${GIT_COMMIT:0:8}
rm -rf target
#打包

docker build -f ./Dockerfile .  -t emis_edda_hsbc --iidfile image.txt
imagestr=`cat image.txt | cut -d':' -f 2`
imageid=${imagestr:0:12}
#推送
docker tag $imageid 10.10.84.156:8015/emis/emis_edda_hsbc:$tagname
docker push 10.10.84.156:8015/emis/emis_edda_hsbc:$tagname
docker tag $imageid 10.196.22.81/emis/emis_edda_hsbc:$tagname
docker push 10.196.22.81/emis/emis_edda_hsbc:$tagname
echo $tagname > imageid.txt
#替换
if [ -f publishScripts/emis_edda_hsbc_dev.sh ]; then eval sed -i 's/CID_TAG_VERSION/$tagname/g' publishScripts/emis_edda_hsbc_dev.sh; fi
if [ -f publishScripts/emis_edda_hsbc_test.sh ]; then eval sed -i 's/CID_TAG_VERSION/$tagname/g' publishScripts/emis_edda_hsbc_test.sh; fi
if [ -f publishScripts/emis_edda_hsbc_prod_pre.sh ]; then eval sed -i 's/CID_TAG_VERSION/$tagname/g' publishScripts/emis_edda_hsbc_prod_pre.sh; fi
if [ -f publishScripts/emis_edda_hsbc_prod.sh ]; then eval sed -i 's/CID_TAG_VERSION/$tagname/g' publishScripts/emis_edda_hsbc_prod.sh; fi
chmod +x publishScripts/*
exit 0
